package csci3033.RecordaNote;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class RecordingAdapter extends ArrayAdapter<Recording>{

	private ArrayList<Recording> recordings;
	
	public RecordingAdapter(Context context, int textViewResourceId,
			ArrayList<Recording> objects) {
		super(context, textViewResourceId, objects);
		this.recordings = objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
        if (view == null) {
            LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = vi.inflate(R.layout.row, null);
        }
        Recording currentRecording = recordings.get(position);
        if (currentRecording != null) {
        	TextView txtName  = (TextView) view.findViewById(R.id.txtName);
        	TextView txtNotes = (TextView) view.findViewById(R.id.txtNotes);
        	txtName.setText(currentRecording.getName());
        	txtNotes.setText(currentRecording.getNotes());
        }
        
        return view;
	}
}
